package org.bigjava.user.service.impl;

import org.bigjava.bean.Topic;
import org.bigjava.common.Constant;
import org.bigjava.user.mapper.TopicMapper;
import org.bigjava.user.service.TopicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class TopicServiceImpl implements TopicService {
    @Autowired
    TopicMapper topicMapper;


    @Override
    //根据id查询话题
    public Topic queryTopicById(long id) {
        return topicMapper.queryTopicById(id);
    }


    //实现热门话题分页
    @Override
    public List<Topic> indexHotTopic(int startPage) {
        return topicMapper.indexHotTopic((startPage - 1) * Constant.hotTopicPage, Constant.hotTopicPage);
    }

    //实现查询总共多少个话题
    @Override
    public int totalRecord() {
        return topicMapper.totalRecord();
    }


    //点击话题进入话题详情页面
    @Override
    public Topic queryTopicByName(String topicName) {
        return topicMapper.queryTopicByName(topicName);
    }

}
